package com.liziyi0914.morearmor.effect;

import com.liziyi0914.morearmor.Utils;
import com.liziyi0914.morearmor.event.Listener;
import com.liziyi0914.morearmor.event.entity.EntityDamageByEntityEvent;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.Items;

import java.util.function.Predicate;

/**
 * 2021/6/30<br>
 * MoreArmor<br>
 *
 * @author huanmeng_qwq
 */
public class WitherSkullEffect extends AbstractEffect{
    @Listener
    public void onDamage(EntityDamageByEntityEvent e){
        if(e.getDamager()==null)return;
        if(!predicateArmor().test(e.getDamager()))return;
        e.getEntity().addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 20 * 5), e.getDamager());
    }
    @Override
    public Predicate<LivingEntity> predicateArmor() {
        return Utils.hasItemArmor(Items.WITHER_SKELETON_SKULL);
    }
}
